﻿Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Text.RegularExpressions
Imports System
Imports System.Data.SqlServerCe
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.Common
Imports System.Reflection

Public Class Form1
    Dim db As DatabaseFactory
    Private dao As EqamDao
    Private pdaUtils As PdaUtils = New PdaUtils

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        db = New DatabaseFactory
        dao = New EqamDao
    End Sub

    Private Sub btnSync_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSync.Click
        doSyncData(cboAction.Text)
    End Sub

    Public Function doSyncData(ByVal actionCode As String) As String
        'Dim output As String = ""
        Dim strName As String = ""
        Dim output As String = processPdaData("402881863343681301334375ef380004")

        Dim encoding As ASCIIEncoding = New ASCIIEncoding
        'ASCIIEncoding encoding=new ASCIIEncoding();
        'string postData="userid="+strId;
        'postData += ("&username="+strName);
        actionCode = "ALL"
        Dim postData As String = "actionCode=" & actionCode & "&pdaData=" & output & "&userName=jason&password=jason123&pdaCode=pda&mode=DUMP_MODULE"
        Dim data As Byte()
        data = encoding.GetBytes(postData)

        Try
            ' Prepare web request...
            Dim url As String = txtIp.Text & "/open/pdaSync.php"

            txtLog.Text = txtLog.Text & url

            Dim myRequest As HttpWebRequest = WebRequest.Create(url)
            myRequest.Method = "POST"
            myRequest.ContentType = "application/x-www-form-urlencoded"
            myRequest.ContentLength = data.Length
            Dim newStream As Stream = myRequest.GetRequestStream()
            ' Send the data.
            newStream.Write(data, 0, data.Length)
            newStream.Close()

            Dim myResponse As HttpWebResponse = myRequest.GetResponse
            Dim newStream2 As Stream = myResponse.GetResponseStream
            Dim reader As StreamReader = New StreamReader(newStream2)
            Dim result As String = reader.ReadToEnd()
            'txtLog.Text = txtLog.Text & result
            output = result
            'processSyncResult(output, actionCode)
            processSyncResult(output)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Return output
    End Function

    Private Sub btnBackup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBackup.Click
        Dim strAppDir As String = Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName)
        Dim full_string As String = ""
        Dim fsWrite As New FileStream(strAppDir + "\Backup" & PdaUtils.getCurrentDate & "-" & PdaUtils.getCurrentTime & ".DAT", FileMode.Create)

        Dim data_writer As New StreamWriter(fsWrite)
        Dim output As String = processPdaData("402881863343681301334375ef380004")
        'full_string = strAppDir + "\Dir.txt"

        data_writer.Write(output)

        data_writer.Close()
        fsWrite.Close()
    End Sub

    Public Function processSyncResult(ByVal output As String) As String
        Dim rgModuleSeparator As Regex = New Regex(Globals.MODULE_SEPARATOR)
        Dim rgModuleDecSeparator As Regex = New Regex(Globals.MODULE_DEC_SEPARATOR)
        Dim rgRecordSeparator As Regex = New Regex(Globals.RECORD_SEPARATOR)
        Dim rgFieldSeparator As Regex = New Regex(Globals.FIELD_SEPARATOR)

        Dim moduleArrs() As String = rgModuleSeparator.Split(output)
        Dim idx As Integer = 0
        For Each moduleArr In moduleArrs
            If (idx = 0) Then
                idx = idx + 1
                Continue For
            End If
            Dim selectedModule As String = moduleArr
            Dim moduleDecArrs() As String = rgModuleDecSeparator.Split(selectedModule)
            Dim moduleCode As String = ""
            For decIdx As Integer = 0 To moduleDecArrs.Length - 1
                'For Each moduleDecArr In moduleDecArrs
                If (decIdx Mod 2 = 0) Then
                    moduleCode = moduleDecArrs(decIdx)
                Else
                    Dim recordArrs() As String = rgRecordSeparator.Split(moduleDecArrs(decIdx))

                    Dim recordIdx As Integer = 0

                    For Each recordArr In recordArrs
                        If (recordArr <> "") Then
                            Dim fieldArrs() As String = rgFieldSeparator.Split(recordArr)
                            Dim hashtable As New Hashtable()
                            Debug.WriteLine("moduleCode=" + moduleCode)
                            Debug.WriteLine("================================")
                            For Each fieldArr In fieldArrs
                                Debug.WriteLine(fieldArr)

                                Dim dataArrs() As String = fieldArr.Split("=")
                                Dim hashKey As String = ""
                                Dim hashValue As String = ""
                                Dim i As Integer = 0
                                For Each dataArr In dataArrs
                                    If i = 0 Then
                                        hashKey = dataArr
                                    Else
                                        hashValue = hashValue + dataArr
                                    End If

                                    i = i + 1
                                Next

                                Debug.WriteLine("hashKey=" + hashKey + ", hashValue=" + hashValue)
                                hashtable.Add(hashKey, hashValue)
                            Next

                            If (Globals.SYNC_PROJECT = moduleCode) Then
                                syncProject(hashtable)
                            ElseIf (Globals.SYNC_PROJECT_WELDER = moduleCode) Then
                                If (recordIdx = 0) Then
                                    Dim projectId As String = hashtable("projectId")

                                    If (projectId <> "") Then
                                        deleteAllProjectWelder(projectId)
                                    End If
                                End If
                                syncProjectWelder(hashtable)

                                recordIdx = recordIdx + 1
                            ElseIf (Globals.SYNC_ENGINEER = moduleCode) Then
                                syncEngineer(hashtable)
                            ElseIf (Globals.SYNC_WELDER = moduleCode) Then
                                syncWelder(hashtable)
                            ElseIf (Globals.SYNC_MATERIAL = moduleCode) Then
                                syncMaterial(hashtable)
                            ElseIf (Globals.SYNC_TUBE_TYPE = moduleCode) Then
                                syncTubeType(hashtable)
                            ElseIf (Globals.SYNC_SYSTEM_TYPE = moduleCode) Then
                                syncSystemType(hashtable)
                            ElseIf (Globals.SYNC_HEAT_NUMBER = moduleCode) Then
                                syncHeatNumber(hashtable)
                            ElseIf (Globals.SYNC_JOINT_TYPE = moduleCode) Then
                                syncJointType(hashtable)
                            ElseIf (Globals.SYNC_REJECT_REASON = moduleCode) Then
                                syncRejectReason(hashtable)
                            ElseIf (Globals.SYNC_AREA = moduleCode) Then
                                syncArea(hashtable)
                            ElseIf (Globals.SYNC_WELDER_SIZE = moduleCode) Then
                                syncWelderSize(hashtable)
                            ElseIf (Globals.SYNC_WELD_MACHINE = moduleCode) Then
                                If (recordIdx = 0) Then
                                    Dim projectId As String = hashtable("projectId")

                                    If (projectId <> "") Then
                                        deleteAllWeldMachine(projectId)
                                    End If
                                End If
                                syncWeldMachine(hashtable)

                                recordIdx = recordIdx + 1
                            ElseIf (Globals.SYNC_COUPON = moduleCode) Then
                                'If (recordIdx = 0) Then
                                'Dim projectId As String = hashtable("projectId")

                                'If (projectId <> "") Then
                                'deleteAllCoupon(projectId)
                                'End If
                                'End If
                                syncCoupon(hashtable)

                                'recordIdx = recordIdx + 1
                            ElseIf (Globals.SYNC_WELDLOG_DETAIL = moduleCode) Then
                                If (recordIdx = 0) Then
                                    Dim projectId As String = hashtable("projectId")

                                    If (projectId <> "") Then
                                        deleteAllWeldlogDetail(projectId)
                                    End If
                                End If

                                syncWeldlogDetail(hashtable)

                                recordIdx = recordIdx + 1
                            ElseIf (Globals.SYNC_WELD_SEQ = moduleCode) Then
                                If (recordIdx = 0) Then
                                    Dim projectId As String = hashtable("projectId")

                                    If (projectId <> "") Then
                                        deleteAllWeldSeq(projectId)
                                    End If

                                End If

                                syncWeldSeq(hashtable)

                                recordIdx = recordIdx + 1
                            ElseIf (Globals.SYNC_WELD_REPLACEMENT = moduleCode) Then
                                If (recordIdx = 0) Then
                                    Dim projectId As String = hashtable("projectId")

                                    If (projectId <> "") Then
                                        deleteAllWeldReplacement(projectId)
                                    End If
                                End If

                                syncWeldReplacement(hashtable)

                                recordIdx = recordIdx + 1
                            End If
                        End If
                    Next
                End If
            Next

            idx = idx + 1
        Next

        MessageBox.Show("Sync Done")
        Return ""
    End Function

    Private Sub btnManual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnManual.Click
        Dim fileDialog As New OpenFileDialog
        Dim output As String = ""
        fileDialog.InitialDirectory = "\Program Files\eqam\"
        fileDialog.Filter = "All files (*.DAT)|*.DAT"
        If fileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
            'MessageBox.Show(fileDialog.FileName)

            'Dim strAppDir As String = Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName)
            Dim strAppDir As String = fileDialog.FileName
            Try
                Dim fsRead As New FileStream(strAppDir, FileMode.Open, FileAccess.Read)
                Dim data_reader As New StreamReader(fsRead)
                Dim line As String = data_reader.ReadLine()

                While Not line Is Nothing
                    txtLog.Text = line
                    output = line
                    line = data_reader.ReadLine()
                End While

                data_reader.Close()

            Catch ex As Exception

                Dim fsWrite As New FileStream(strAppDir, FileMode.Create)
                fsWrite.Close()

            End Try

        End If
        'Dim output As String = "SUCCESS###PROJECT,,,:::id=8a81818233255e56013325ba16880002@@@projectName=INFENEON-01@@@supervisorUser=@@@statusCode=A@@@supervisorId=@@@addBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170512@@@datetimeUpdateDATE=20111023@@@datetimeUpdateTIME=233202@@@updateBy=1@@@supervisorName=###WELDER,,,:::welderId=8a818182332539260133254adfe30003@@@userName=CHINLONG@@@welderName=EE CHIN LONG@@@pdaPassword=123456@@@statusCode=A@@@welderCompanyCode=IBM@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=150343@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=150343@@@welderCompanyName=IBM:::welderId=8a818182332539260133254b416c0004@@@userName=SOONKIET@@@welderName=TEOH SOON KIET@@@pdaPassword=123456@@@statusCode=A@@@welderCompanyCode=IBM@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=150408@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=150408@@@welderCompanyName=IBM:::welderId=8a818182332539260133254b8ba40005@@@userName=NORAZMAN@@@welderName=NORAZMAN@@@pdaPassword=123456@@@statusCode=A@@@welderCompanyCode=IBM@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=150427@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=150427@@@welderCompanyName=IBM###MATERIAL,,,:::material=CARBON STEEL@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=154556@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=154556@@@status=A:::material=CPVC@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=154620@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=154620@@@status=A:::material=PE@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=154634@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=154634@@@status=A:::material=PP@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=154632@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=154632@@@status=A:::material=PVC@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=154623@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=154623@@@status=A:::material=PVDF@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=154629@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=154629@@@status=A:::material=STAINLESS STEEL@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=154553@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=154553@@@status=A###TUBE_TYPE,,,###SYSTEM_TYPE,,,:::id=8a81818233255e56013325bedbe80014@@@systemTypeName=ACID@@@status=A@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=171025@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=171025@@@projectId=8a81818233255e56013325ba16880002:::id=8a81818233255e56013325beef310015@@@systemTypeName=CWC@@@status=A@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=171029@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=171029@@@projectId=8a81818233255e56013325ba16880002###HEAT_NUMBER,,,:::id=8a81818233255e56013325beb5930012@@@heatNumberDesc=H01@@@status=A@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=171015@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=171015@@@projectId=8a81818233255e56013325ba16880002:::id=8a81818233255e56013325bec2260013@@@heatNumberDesc=H02@@@status=A@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=171018@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=171018@@@projectId=8a81818233255e56013325ba16880002###JOINT_TYPE,,,:::jointTypeCode=Pipe@@@jointTypeName=PIPE@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110921@@@datetimeAddTIME=144634@@@datetimeUpdateDATE=20110921@@@datetimeUpdateTIME=144634@@@status=A:::jointTypeCode=Tube@@@jointTypeName=TUBE@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110921@@@datetimeAddTIME=144617@@@datetimeUpdateDATE=20110921@@@datetimeUpdateTIME=144617@@@status=A###REJECT_REASON,,,:::id=8a818182328f2b1701328f2b206c0001@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110922@@@datetimeAddTIME=112600@@@datetimeUpdateDATE=20110922@@@datetimeUpdateTIME=112600@@@reason=Misalignment:::id=8a818182328f2b1701328f2b206c0002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110922@@@datetimeAddTIME=112600@@@datetimeUpdateDATE=20110922@@@datetimeUpdateTIME=112600@@@reason=Concavity:::id=8a818182328f2b1701328f2b206c0003@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110922@@@datetimeAddTIME=112600@@@datetimeUpdateDATE=20110922@@@datetimeUpdateTIME=112600@@@reason=Convexity:::id=8a818182328f2b1701328f2b206c0004@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110922@@@datetimeAddTIME=112600@@@datetimeUpdateDATE=20110922@@@datetimeUpdateTIME=112600@@@reason=Bead width:::id=8a818182328f2b1701328f2b206c0005@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110922@@@datetimeAddTIME=112600@@@datetimeUpdateDATE=20110922@@@datetimeUpdateTIME=112600@@@reason=Discoloration:::id=8a818182328f2b1701328f2b206c0006@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110922@@@datetimeAddTIME=112600@@@datetimeUpdateDATE=20110922@@@datetimeUpdateTIME=112600@@@reason=Other###AREA,,,:::id=8a81818233255e56013325bf4e390016@@@areaName=LAB-CHEMICAL@@@status=A@@@seq=1@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=171054@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=171135@@@projectId=8a81818233255e56013325ba16880002:::id=8a81818233255e56013325bf6ae90017@@@areaName=LAB-BB@@@status=A@@@seq=2@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=171101@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=171135@@@projectId=8a81818233255e56013325ba16880002###WELDER_SIZE,,,:::id=402881843292845e01329294465d0001@@@weldSize=1/16@@@projectId=8a81818232869e97013286a3e5610001@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110923@@@datetimeAddTIME=031943@@@datetimeUpdateDATE=20110923@@@datetimeUpdateTIME=031943@@@welderId=8a818182328aa46e01328aa9ef810001:::id=402881843292845e013292944bfa0002@@@weldSize=1/2@@@projectId=8a81818232869e97013286a3e5610001@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110923@@@datetimeAddTIME=031944@@@datetimeUpdateDATE=20110923@@@datetimeUpdateTIME=031944@@@welderId=8a818182328aa46e01328aa9ef810001:::id=402881843292845e0132929b79900003@@@weldSize=1/12@@@projectId=8a81818232869e97013286a3e5610001@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110923@@@datetimeAddTIME=032735@@@datetimeUpdateDATE=20110923@@@datetimeUpdateTIME=032735@@@welderId=8a818182328aa46e01328aa9ef810001:::id=402881843292845e0132929bbeb70005@@@weldSize=1/16@@@projectId=8a81818232869e97013286a3e5610001@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110923@@@datetimeAddTIME=032753@@@datetimeUpdateDATE=20110923@@@datetimeUpdateTIME=032753@@@welderId=8a818182328aa46e01328aaa73760002:::id=402881843292845e0132929bc4350006@@@weldSize=1/2@@@projectId=8a81818232869e97013286a3e5610001@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110923@@@datetimeAddTIME=032754@@@datetimeUpdateDATE=20110923@@@datetimeUpdateTIME=032754@@@welderId=8a818182328aa46e01328aaa73760002:::id=402881843292845e0132929bd7fc0007@@@weldSize=1/16@@@projectId=8a81818232869e97013286a3e5610001@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20110923@@@datetimeAddTIME=032759@@@datetimeUpdateDATE=20110923@@@datetimeUpdateTIME=032759@@@welderId=8a818182328aa46e01328aab42ad0003:::id=8a81818233255e56013325bd43080008@@@weldSize=1-1/4@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170840@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170840@@@welderId=8a818182332539260133254adfe30003:::id=8a81818233255e56013325bd63900009@@@weldSize=3/8@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170848@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170848@@@welderId=8a818182332539260133254adfe30003:::id=8a81818233255e56013325bd741a000a@@@weldSize=1-1/2@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170852@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170852@@@welderId=8a818182332539260133254adfe30003:::id=8a81818233255e56013325bd83ab000b@@@weldSize=3/4@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170856@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170856@@@welderId=8a818182332539260133254adfe30003:::id=8a81818233255e56013325bdf735000e@@@weldSize=1/2@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170926@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170926@@@welderId=8a818182332539260133254b416c0004:::id=8a81818233255e56013325be2f4c000f@@@weldSize=3/8@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170940@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170940@@@welderId=8a818182332539260133254b416c0004:::id=8a81818233255e56013325be3da40010@@@weldSize=1-1/2@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170944@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170944@@@welderId=8a818182332539260133254b416c0004:::id=8a81818233255e56013325be4ad30011@@@weldSize=3/4@@@projectId=8a81818233255e56013325ba16880002@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20111021@@@datetimeAddTIME=170947@@@datetimeUpdateDATE=20111021@@@datetimeUpdateTIME=170947@@@welderId=8a818182332539260133254b416c0004"

        processSyncResult(output)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim output As String = processPdaData("8a81818233255e56013325ba16880002")
        Debug.WriteLine(output)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        
        Dim output As String = "SUCCESS###PROJECT,,,:::id=aa81bc073d7ae268013d85e7d9190007@@@projectName=120001@@@supervisorUser=@@@statusCode=ACTIVE@@@supervisorId=@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=114636@@@datetimeUpdateDATE=20130325@@@datetimeUpdateTIME=163436@@@updateBy=297ef6af368ada2001368adeed190001@@@supervisorName=###PROJECT_WELDER,,,:::projectId=aa81bc073d7ae268013d85e7d9190007@@@welderId=aa81bc07388b935201388da371b60006@@@clientWelderId=null:::projectId=aa81bc073d7ae268013d85e7d9190007@@@welderId=aa81bc07388e554f01389844e9eb0007@@@clientWelderId=null###ENGINEER,,,:::engineerId=297ef6af368ada2001368adeed190001@@@userName=JACLYN@@@engineerName=@@@pdaPassword=123456@@@statusCode=A@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=113527@@@datetimeUpdateDATE=20121106@@@datetimeUpdateTIME=093656:::engineerId=297ef6af368ada2001368ae05a760002@@@userName=JASON@@@engineerName=@@@pdaPassword=123456@@@statusCode=A@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=113700@@@datetimeUpdateDATE=20120407@@@datetimeUpdateTIME=113854:::engineerId=297ef6af368ada2001368ae1e25d0003@@@userName=BENNY@@@engineerName=@@@pdaPassword=123456@@@statusCode=A@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=113841@@@datetimeUpdateDATE=20120407@@@datetimeUpdateTIME=113841:::engineerId=aa81bc07388e554f01389847a9690009@@@userName=LOON@@@engineerName=@@@pdaPassword=123456@@@statusCode=A@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120718@@@datetimeAddTIME=121029@@@datetimeUpdateDATE=20120718@@@datetimeUpdateTIME=121029:::engineerId=aa81bc07395ebe6b01396b2f14d10006@@@userName=WENDY LIM@@@engineerName=@@@pdaPassword=123456@@@statusCode=A@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=aa81bc07395ebe6b01396b2f14d10006@@@datetimeAddDATE=20120828@@@datetimeAddTIME=110331@@@datetimeUpdateDATE=20120926@@@datetimeUpdateTIME=134041:::engineerId=aa81bc0739f6231a013aaa604a5c0036@@@userName=BONG@@@engineerName=@@@pdaPassword=123456@@@statusCode=A@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121029@@@datetimeAddTIME=103608@@@datetimeUpdateDATE=20121029@@@datetimeUpdateTIME=104317:::engineerId=aa81bc073bf9cbe5013c3d8ffa5d002d@@@userName=KC@@@engineerName=@@@pdaPassword=123456@@@statusCode=A@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20130115@@@datetimeAddTIME=173511@@@datetimeUpdateDATE=20130115@@@datetimeUpdateTIME=173511###WELDER,,,:::welderId=aa81bc07388b935201388da371b60006@@@userName=JEN@@@welderName=CHAN WEI JEN@@@pdaPassword=1234@@@statusCode=A@@@welderCompanyCode=WM@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=103455@@@datetimeUpdateDATE=20120910@@@datetimeUpdateTIME=094757@@@welderCompanyName=WENG MENG ENGINEERING@@@clientWelderId=null:::welderId=aa81bc07388e554f01389844e9eb0007@@@userName=MENG@@@welderName=KEE OOI MENG@@@pdaPassword=1234@@@statusCode=A@@@welderCompanyCode=WM@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120718@@@datetimeAddTIME=120729@@@datetimeUpdateDATE=20120910@@@datetimeUpdateTIME=094816@@@welderCompanyName=WENG MENG ENGINEERING@@@clientWelderId=null###JOINT_TYPE,,,:::jointTypeCode=E@@@jointTypeName=ELBOW@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=202102@@@datetimeUpdateDATE=20121119@@@datetimeUpdateTIME=115253@@@status=A:::jointTypeCode=ET@@@jointTypeName=EQUAL TEE@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=201951@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=201951@@@status=A:::jointTypeCode=G@@@jointTypeName=GLAND@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=202229@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=202229@@@status=A:::jointTypeCode=PRV@@@jointTypeName=PRESSURE REDUCING VA@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121029@@@datetimeAddTIME=112114@@@datetimeUpdateDATE=20121029@@@datetimeUpdateTIME=112114@@@status=A:::jointTypeCode=RD@@@jointTypeName=REDUCER@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120731@@@datetimeAddTIME=112545@@@datetimeUpdateDATE=20120731@@@datetimeUpdateTIME=112545@@@status=A:::jointTypeCode=RT@@@jointTypeName=REDUCING TEE@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=201850@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=201936@@@status=A:::jointTypeCode=T@@@jointTypeName=TUBE@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=201830@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=201830@@@status=A:::jointTypeCode=V@@@jointTypeName=VALVE@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=202017@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=202017@@@status=A###WELDER_SIZE,,,:::id=297ef6af3dc3c901013dc44ba6010004@@@weldSize=1""@@@projectId=aa81bc073d7ae268013d85e7d9190007@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20130401@@@datetimeAddTIME=143204@@@datetimeUpdateDATE=20130401@@@datetimeUpdateTIME=143204@@@welderId=aa81bc07388b935201388da371b60006:::id=297ef6af3dc3c901013dc44bac970005@@@weldSize=1/2""@@@projectId=aa81bc073d7ae268013d85e7d9190007@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20130401@@@datetimeAddTIME=143206@@@datetimeUpdateDATE=20130401@@@datetimeUpdateTIME=143206@@@welderId=aa81bc07388b935201388da371b60006:::id=297ef6af3dc3c901013dc44bb3450006@@@weldSize=1/4""@@@projectId=aa81bc073d7ae268013d85e7d9190007@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20130401@@@datetimeAddTIME=143208@@@datetimeUpdateDATE=20130401@@@datetimeUpdateTIME=143208@@@welderId=aa81bc07388b935201388da371b60006:::id=297ef6af3dc3c901013dc44bc3c80007@@@weldSize=1""@@@projectId=aa81bc073d7ae268013d85e7d9190007@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20130401@@@datetimeAddTIME=143212@@@datetimeUpdateDATE=20130401@@@datetimeUpdateTIME=143212@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=297ef6af3dc3c901013dc44bc93d0008@@@weldSize=1/2""@@@projectId=aa81bc073d7ae268013d85e7d9190007@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20130401@@@datetimeAddTIME=143213@@@datetimeUpdateDATE=20130401@@@datetimeUpdateTIME=143213@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=297ef6af3dc3c901013dc44bcf770009@@@weldSize=1/4""@@@projectId=aa81bc073d7ae268013d85e7d9190007@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20130401@@@datetimeAddTIME=143215@@@datetimeUpdateDATE=20130401@@@datetimeUpdateTIME=143215@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=aa81bc0737ffa1d20138239ec8110023@@@weldSize=1/2""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=203004@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=203004@@@welderId=aa81bc0737ffa1d20138238a443f0018:::id=aa81bc0737ffa1d20138239ed2bf0024@@@weldSize=1""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=203007@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=203007@@@welderId=aa81bc0737ffa1d20138238a443f0018:::id=aa81bc0737ffa1d20138239f026a0025@@@weldSize=1/2""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=203019@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=203019@@@welderId=aa81bc0737ffa1d2013823920fbf0020:::id=aa81bc0737ffa1d20138239f075c0026@@@weldSize=1""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=203021@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=203021@@@welderId=aa81bc0737ffa1d2013823920fbf0020:::id=aa81bc07388b935201388daa564d0009@@@weldSize=1/2""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104227@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104227@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc07388b935201388daa5bea000a@@@weldSize=1/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104228@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104228@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc07388b935201388daa60ad000b@@@weldSize=3/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104229@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104229@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc07388b935201388daa6428000c@@@weldSize=3/8""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104230@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104230@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc07388b935201388daa8462000d@@@weldSize=1/2""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104238@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104238@@@welderId=aa81bc07388b935201388da5eb710007:::id=aa81bc07388b935201388daa88a7000e@@@weldSize=1/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104239@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104239@@@welderId=aa81bc07388b935201388da5eb710007:::id=aa81bc07388b935201388daa8c22000f@@@weldSize=3/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104240@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104240@@@welderId=aa81bc07388b935201388da5eb710007:::id=aa81bc07388b935201388daa90770010@@@weldSize=3/8""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104241@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104241@@@welderId=aa81bc07388b935201388da5eb710007:::id=aa81bc07388b935201388daaa17f0011@@@weldSize=1/2""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104246@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104246@@@welderId=aa81bc07388b935201388da690e80008:::id=aa81bc07388b935201388daaa5d40012@@@weldSize=1/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104247@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104247@@@welderId=aa81bc07388b935201388da690e80008:::id=aa81bc07388b935201388daaa9100013@@@weldSize=3/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104248@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104248@@@welderId=aa81bc07388b935201388da690e80008:::id=aa81bc07388b935201388daaac4c0014@@@weldSize=3/8""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120716@@@datetimeAddTIME=104249@@@datetimeUpdateDATE=20120716@@@datetimeUpdateTIME=104249@@@welderId=aa81bc07388b935201388da690e80008:::id=aa81bc0738b7e8330138c28f1d1f0040@@@weldSize=1/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120726@@@datetimeAddTIME=171235@@@datetimeUpdateDATE=20120726@@@datetimeUpdateTIME=171235@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=aa81bc0738b7e8330138c28f256c0041@@@weldSize=3/8""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120726@@@datetimeAddTIME=171237@@@datetimeUpdateDATE=20120726@@@datetimeUpdateTIME=171237@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=aa81bc0738b7e8330138c28f36d10042@@@weldSize=1/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120726@@@datetimeAddTIME=171241@@@datetimeUpdateDATE=20120726@@@datetimeUpdateTIME=171241@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=aa81bc0738b7e8330138c28f3ff90043@@@weldSize=1/2""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120726@@@datetimeAddTIME=171244@@@datetimeUpdateDATE=20120726@@@datetimeUpdateTIME=171244@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=aa81bc0738b7e8330138c28f4b920044@@@weldSize=3/4""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120726@@@datetimeAddTIME=171247@@@datetimeUpdateDATE=20120726@@@datetimeUpdateTIME=171247@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=aa81bc073983d6d10139addf26380004@@@weldSize=1""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120910@@@datetimeAddTIME=095046@@@datetimeUpdateDATE=20120910@@@datetimeUpdateTIME=095046@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc073983d6d10139addf478b0005@@@weldSize=1""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120910@@@datetimeAddTIME=095054@@@datetimeUpdateDATE=20120910@@@datetimeUpdateTIME=095054@@@welderId=aa81bc07388b935201388da5eb710007:::id=aa81bc073983d6d10139addf7e3b0006@@@weldSize=1""@@@projectId=aa81bc07388b935201388d9a67040004@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120910@@@datetimeAddTIME=095108@@@datetimeUpdateDATE=20120910@@@datetimeUpdateTIME=095108@@@welderId=aa81bc07388e554f01389844e9eb0007:::id=aa81bc073b5ed4f9013b5ff537e60004@@@weldSize=1""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121203@@@datetimeAddTIME=165004@@@datetimeUpdateDATE=20121203@@@datetimeUpdateTIME=165004@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc073b5ed4f9013b5ff53c2c0005@@@weldSize=1/2""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121203@@@datetimeAddTIME=165005@@@datetimeUpdateDATE=20121203@@@datetimeUpdateTIME=165005@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc073b5ed4f9013b5ff541e90006@@@weldSize=3/4""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121203@@@datetimeAddTIME=165006@@@datetimeUpdateDATE=20121203@@@datetimeUpdateTIME=165006@@@welderId=aa81bc07388b935201388da371b60006:::id=aa81bc073b5ed4f9013b5ff5635b0007@@@weldSize=1""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121203@@@datetimeAddTIME=165015@@@datetimeUpdateDATE=20121203@@@datetimeUpdateTIME=165015@@@welderId=aa81bc0737ffa1d201382390ba21001f:::id=aa81bc073b5ed4f9013b5ff567ff0008@@@weldSize=1/2""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121203@@@datetimeAddTIME=165016@@@datetimeUpdateDATE=20121203@@@datetimeUpdateTIME=165016@@@welderId=aa81bc0737ffa1d201382390ba21001f:::id=aa81bc073b5ed4f9013b5ff56f810009@@@weldSize=3/4""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121203@@@datetimeAddTIME=165018@@@datetimeUpdateDATE=20121203@@@datetimeUpdateTIME=165018@@@welderId=aa81bc0737ffa1d201382390ba21001f:::id=aa81bc073b5ed4f9013b5ff57397000a@@@weldSize=1/4""@@@projectId=aa81bc0737ffa1d20138237fbe030006@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121203@@@datetimeAddTIME=165019@@@datetimeUpdateDATE=20121203@@@datetimeUpdateTIME=165019@@@welderId=aa81bc0737ffa1d201382390ba21001f:::id=aa81bc073b63333c013ba7b475340014@@@weldSize=1/4""@@@projectId=aa81bc0739f6231a0139f6d6a777000a@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121217@@@datetimeAddTIME=151159@@@datetimeUpdateDATE=20121217@@@datetimeUpdateTIME=151159@@@welderId=aa81bc07388b935201388da690e80008:::id=aa81bc073b63333c013ba7b47b300015@@@weldSize=1/2""@@@projectId=aa81bc0739f6231a0139f6d6a777000a@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121217@@@datetimeAddTIME=151201@@@datetimeUpdateDATE=20121217@@@datetimeUpdateTIME=151201@@@welderId=aa81bc07388b935201388da690e80008:::id=aa81bc073bcaa03d013bdb4a93a00006@@@weldSize=1/4""@@@projectId=aa81bc0739f6231a0139f6d6a777000a@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121227@@@datetimeAddTIME=153636@@@datetimeUpdateDATE=20121227@@@datetimeUpdateTIME=153636@@@welderId=aa81bc07388b935201388da5eb710007:::id=aa81bc073bcaa03d013bdb4a9da20007@@@weldSize=1/2""@@@projectId=aa81bc0739f6231a0139f6d6a777000a@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121227@@@datetimeAddTIME=153638@@@datetimeUpdateDATE=20121227@@@datetimeUpdateTIME=153638@@@welderId=aa81bc07388b935201388da5eb710007###REJECT_REASON,,,:::id=297ef6af368b9a8d01368bc696a70009@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=154829@@@datetimeUpdateDATE=20120407@@@datetimeUpdateTIME=154829@@@reason=Misalignment:::id=297ef6af368b9a8d01368bc6c9bf000a@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=154842@@@datetimeUpdateDATE=20120407@@@datetimeUpdateTIME=154842@@@reason=Concavity:::id=297ef6af368b9a8d01368bc6eee7000b@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=154852@@@datetimeUpdateDATE=20120407@@@datetimeUpdateTIME=154852@@@reason=Convexity:::id=297ef6af368b9a8d01368bc72419000c@@@addBy=1@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120407@@@datetimeAddTIME=154905@@@datetimeUpdateDATE=20120607@@@datetimeUpdateTIME=152319@@@reason=Bead meandering:::id=297ef6af368b9a8d01368bc74ec1000d@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=154916@@@datetimeUpdateDATE=20120407@@@datetimeUpdateTIME=154916@@@reason=Discoloration:::id=297ef6af368b9a8d01368bc777f6000e@@@addBy=1@@@updateBy=1@@@datetimeAddDATE=20120407@@@datetimeAddTIME=154927@@@datetimeUpdateDATE=20120407@@@datetimeUpdateTIME=154927@@@reason=Other###MATERIAL,,,:::material=SS304@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121119@@@datetimeAddTIME=115339@@@datetimeUpdateDATE=20121119@@@datetimeUpdateTIME=115339@@@status=A:::material=SS304L@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121119@@@datetimeAddTIME=115347@@@datetimeUpdateDATE=20121119@@@datetimeUpdateTIME=115347@@@status=A:::material=SS316@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20121119@@@datetimeAddTIME=115413@@@datetimeUpdateDATE=20121119@@@datetimeUpdateTIME=115413@@@status=A:::material=SS316L@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@datetimeAddDATE=20120625@@@datetimeAddTIME=202332@@@datetimeUpdateDATE=20120625@@@datetimeUpdateTIME=202332@@@status=A###SYSTEM_TYPE,,,:::id=aa81bc073d7ae268013d85ec88120013@@@systemTypeName=PN2@@@drawingNumber=IFKM-PN2-CR001-L3@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115143@@@datetimeUpdateDATE=20130325@@@datetimeUpdateTIME=112217@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85ecbf3f0014@@@systemTypeName=PN2@@@drawingNumber=IFKM-PN2-NCR-001@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115158@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=115158@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85ed04180015@@@systemTypeName=PO2@@@drawingNumber=IFKM-PO2-CR-001-L2@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115215@@@datetimeUpdateDATE=20130325@@@datetimeUpdateTIME=112051@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85ed38570016@@@systemTypeName=PN2@@@drawingNumber=IFKM-PN2-CR-001-L2@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115229@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=115240@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85ede5410017@@@systemTypeName=PO2@@@drawingNumber=IFKM-PO2-NCR-001@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115313@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=115313@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d9f8fecf40020@@@systemTypeName=PO2@@@drawingNumber=IFKM-PO2-CR-001-L3@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130325@@@datetimeAddTIME=112042@@@datetimeUpdateDATE=20130325@@@datetimeUpdateTIME=112225@@@projectId=aa81bc073d7ae268013d85e7d9190007###HEAT_NUMBER,,,:::id=aa81bc073d7ae268013d85e9cc0f000a@@@heatNumberDesc=T001@@@jointTypeCode=@@@jointTypeName=@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=114844@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=114844@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85e9f6a9000b@@@heatNumberDesc=E001@@@jointTypeCode=@@@jointTypeName=@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=114855@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=114855@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85ea2b65000c@@@heatNumberDesc=RT001@@@jointTypeCode=@@@jointTypeName=@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=114909@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=114909@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85ea71d5000d@@@heatNumberDesc=V001@@@jointTypeCode=@@@jointTypeName=@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=114927@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=114927@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85ea8463000e@@@heatNumberDesc=G001@@@jointTypeCode=@@@jointTypeName=@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=114931@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=114931@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85eac0b0000f@@@heatNumberDesc=R001@@@jointTypeCode=@@@jointTypeName=@@@status=A@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=114947@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=114947@@@projectId=aa81bc073d7ae268013d85e7d9190007###AREA,,,:::id=aa81bc073d7ae268013d85ee95b50018@@@areaName=NCR@@@status=A@@@seq=0@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115358@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=115358@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85eeb86f0019@@@areaName=CR-L1@@@status=A@@@seq=0@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115407@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=115407@@@projectId=aa81bc073d7ae268013d85e7d9190007:::id=aa81bc073d7ae268013d85eecf82001a@@@areaName=CR-L2@@@status=A@@@seq=0@@@addBy=aa81bc0739f6231a013aaa604a5c0036@@@updateBy=aa81bc0739f6231a013aaa604a5c0036@@@datetimeAddDATE=20130320@@@datetimeAddTIME=115413@@@datetimeUpdateDATE=20130320@@@datetimeUpdateTIME=115413@@@projectId=aa81bc073d7ae268013d85e7d9190007###WELD_MACHINE,,,:::projectId=aa81bc073d7ae268013d85e7d9190007@@@projectWeldMachineId=aa81bc073d7ae268013d85e812780008@@@weldMachineId=aa81bc0737ffa1d201382380925b0009@@@weldMachineModel=M200@@@serialNumber=M6423@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@calibrationDateDATE=20130528@@@calibrationDateTIME=000000@@@datetimeAddDATE=20120625@@@datetimeAddTIME=195704@@@datetimeUpdateDATE=20130102@@@datetimeUpdateTIME=101416@@@status=A:::projectId=aa81bc073d7ae268013d85e7d9190007@@@projectWeldMachineId=aa81bc073d7ae268013da0af397a0024@@@weldMachineId=aa81bc07388b935201388d9d03a80005@@@weldMachineModel=M200@@@serialNumber=M5786@@@addBy=297ef6af368ada2001368adeed190001@@@updateBy=297ef6af368ada2001368adeed190001@@@calibrationDateDATE=20130612@@@calibrationDateTIME=000000@@@datetimeAddDATE=20120716@@@datetimeAddTIME=102753@@@datetimeUpdateDATE=20130205@@@datetimeUpdateTIME=095056@@@status=A###WELD_REPLACEMENT,,,###COUPON,,,###COUPON_SYSTEM,,,###WELDLOG_DETAIL,,,###WELD_SEQ,,,"
        'Dim output As String = txtLog.Text
        processSyncResult(output)
    End Sub

    Public Function processPdaData(ByVal projectId As String) As String
        Dim output As String = ""

        output = output & Globals.MODULE_SEPARATOR + "WELD_REPLACEMENT" + Globals.MODULE_DEC_SEPARATOR & processPdaWeldReplacementData(projectId)
        output = output & Globals.MODULE_SEPARATOR + "COUPON" + Globals.MODULE_DEC_SEPARATOR & processPdaCouponData(projectId)
        output = output & Globals.MODULE_SEPARATOR + "COUPON_SYSTEM" + Globals.MODULE_DEC_SEPARATOR & processPdaCouponSystemData(projectId)
        output = output & Globals.MODULE_SEPARATOR + "WELDLOG_DETAIL" + Globals.MODULE_DEC_SEPARATOR & processPdaWeldlogDetailData(projectId)
        output = output & Globals.MODULE_SEPARATOR + "WELD_SEQ" + Globals.MODULE_DEC_SEPARATOR & processPdaWeldSeqData(projectId)

        txtLog.Text = output
        MessageBox.Show("Backup Done")
        Return output
    End Function

    Public Function processPdaWeldlogDetailData(ByVal projectId As String) As String
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""

        SQL = "SELECT * FROM eqam_weldlog_detail"

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows               
                output = output & Globals.RECORD_SEPARATOR & "WELDLOG_DETAIL_ID=" & dataRow.Item("WELDLOG_DETAIL_ID")
                If (IsDBNull(dataRow.Item("S_WELDLOG_DETAIL_ID")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "S_WELDLOG_DETAIL_ID=" & dataRow.Item("S_WELDLOG_DETAIL_ID")
                End If

                output = output & Globals.FIELD_SEPARATOR & "BARCODE=" & dataRow.Item("BARCODE")
                output = output & Globals.FIELD_SEPARATOR & "BARCODE_REF=" & dataRow.Item("BARCODE_REF")
                output = output & Globals.FIELD_SEPARATOR & "SEQ=" & dataRow.Item("SEQ")
                output = output & Globals.FIELD_SEPARATOR & "COUPON_CODE=" & dataRow.Item("COUPON_CODE")
                output = output & Globals.FIELD_SEPARATOR & "COUPON_TYPE=" & dataRow.Item("COUPON_TYPE")
                output = output & Globals.FIELD_SEPARATOR & "WELDER_USER_ID=" & dataRow.Item("WELDER_USER_ID")
                output = output & Globals.FIELD_SEPARATOR & "WELD_DATE=" & dataRow.Item("WELD_DATE")
                output = output & Globals.FIELD_SEPARATOR & "WELD_TIME=" & dataRow.Item("WELD_TIME")

                If (IsDBNull(dataRow.Item("QC_USER_ID")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "QC_USER_ID=" & dataRow.Item("QC_USER_ID")
                End If

                If (IsDBNull(dataRow.Item("QC_DATE")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "QC_DATE=" & dataRow.Item("QC_DATE")
                End If

                If (IsDBNull(dataRow.Item("QC_TIME")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "QC_TIME=" & dataRow.Item("QC_TIME")
                End If

                If (IsDBNull(dataRow.Item("QC_STATUS")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "QC_STATUS=" & dataRow.Item("QC_STATUS")
                End If

                If (IsDBNull(dataRow.Item("REJECT_REASON")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "REJECT_REASON=" & dataRow.Item("REJECT_REASON")
                End If

                If (IsDBNull(dataRow.Item("REPLACEMENT_ID")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "REPLACEMENT_ID=" & dataRow.Item("REPLACEMENT_ID")
                End If

                If (IsDBNull(dataRow.Item("REJECT_BARCODE")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "REJECT_BARCODE=" & dataRow.Item("REJECT_BARCODE")
                End If

                If (IsDBNull(dataRow.Item("REPLACE_BARCODE")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "REPLACE_BARCODE=" & dataRow.Item("REPLACE_BARCODE")
                End If

                If (IsDBNull(dataRow.Item("REMARK")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "REMARK=" & dataRow.Item("REMARK")
                End If

                output = output & Globals.FIELD_SEPARATOR & "STATUS_CODE=" & dataRow.Item("STATUS_CODE")
                output = output & Globals.FIELD_SEPARATOR & "SYSTEM_TYPE_ID=" & dataRow.Item("SYSTEM_TYPE_ID")
                output = output & Globals.FIELD_SEPARATOR & "SYSTEM_TYPE_NAME=" & dataRow.Item("SYSTEM_TYPE_NAME")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_ID_1=" & dataRow.Item("HEAT_NUMBER_ID_1")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_NAME_1=" & dataRow.Item("HEAT_NUMBER_NAME_1")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_ID_2=" & dataRow.Item("HEAT_NUMBER_ID_2")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_NAME_2=" & dataRow.Item("HEAT_NUMBER_NAME_2")
                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_CODE_1=" & dataRow.Item("JOINT_TYPE_CODE_1")
                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_NAME_1=" & dataRow.Item("JOINT_TYPE_NAME_1")
                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_CODE_2=" & dataRow.Item("JOINT_TYPE_CODE_2")
                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_NAME_2=" & dataRow.Item("JOINT_TYPE_NAME_2")
                output = output & Globals.FIELD_SEPARATOR & "PDA_CODE=" & dataRow.Item("PDA_CODE")
                output = output & Globals.FIELD_SEPARATOR & "ZONE_ID=" & dataRow.Item("ZONE_ID")
                output = output & Globals.FIELD_SEPARATOR & "ZONE=" & dataRow.Item("ZONE")

                output = output & Globals.FIELD_SEPARATOR & "ADD_BY=" & dataRow.Item("ADD_BY")
                output = output & Globals.FIELD_SEPARATOR & "DATE_ADD=" & dataRow.Item("DATE_ADD")
                output = output & Globals.FIELD_SEPARATOR & "TIME_ADD=" & dataRow.Item("TIME_ADD")
                output = output & Globals.FIELD_SEPARATOR & "DATE_UPDATE=" & dataRow.Item("DATE_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "TIME_UPDATE=" & dataRow.Item("TIME_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "UPDATE_BY=" & dataRow.Item("UPDATE_BY")
            Next
        End If

        Return output
    End Function

    Public Function processPdaWeldSeqData(ByVal projectId As String) As String
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""


        SQL = "SELECT * FROM eqam_weld_seq"
        'SQL = "SELECT * FROM eqam_coupon WHERE PROJECT_ID = @PROJECT_ID"
        'paramList.Add("@PROJECT_ID", projectId)

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                output = output & Globals.RECORD_SEPARATOR & "SEQ_ID=" & dataRow.Item("SEQ_ID")
                If (IsDBNull(dataRow.Item("S_SEQ_ID")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "S_SEQ_ID=" & dataRow.Item("S_SEQ_ID")
                End If
                'output = output & Globals.RECORD_SEPARATOR & "S_SEQ_ID=" & dataRow.Item("S_SEQ_ID"))
                output = output & Globals.FIELD_SEPARATOR & "PROJECT_ID=" & dataRow.Item("PROJECT_ID")
                output = output & Globals.FIELD_SEPARATOR & "ZONE=" & dataRow.Item("ZONE")
                output = output & Globals.FIELD_SEPARATOR & "SEQ=" & dataRow.Item("SEQ")
                output = output & Globals.FIELD_SEPARATOR & "BARCODE=" & dataRow.Item("BARCODE")
                output = output & Globals.FIELD_SEPARATOR & "ADD_BY=" & dataRow.Item("ADD_BY")
                output = output & Globals.FIELD_SEPARATOR & "DATE_ADD=" & dataRow.Item("DATE_ADD")
                output = output & Globals.FIELD_SEPARATOR & "TIME_ADD=" & dataRow.Item("TIME_ADD")
                output = output & Globals.FIELD_SEPARATOR & "DATE_UPDATE=" & dataRow.Item("DATE_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "TIME_UPDATE=" & dataRow.Item("TIME_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "UPDATE_BY=" & dataRow.Item("UPDATE_BY")
                output = output & Globals.FIELD_SEPARATOR & "PDA_CODE=" & dataRow.Item("PDA_CODE")
            Next
        End If

        Return output
    End Function

    Public Function processPdaWeldReplacementData(ByVal projectId As String) As String
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""


        SQL = "SELECT * FROM eqam_weld_replacement"
        'SQL = "SELECT * FROM eqam_coupon WHERE PROJECT_ID = @PROJECT_ID"
        'paramList.Add("@PROJECT_ID", projectId)

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                output = output & Globals.RECORD_SEPARATOR & "REPLACEMENT_ID=" & dataRow.Item("REPLACEMENT_ID")
                If (IsDBNull(dataRow.Item("S_REPLACEMENT_ID")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "S_REPLACEMENT_ID=" & dataRow.Item("S_REPLACEMENT_ID")
                End If

                output = output & Globals.FIELD_SEPARATOR & "REJECT_BARCODE=" & dataRow.Item("REJECT_BARCODE")
                output = output & Globals.FIELD_SEPARATOR & "REPLACE_BARCODE=" & dataRow.Item("REPLACE_BARCODE")
                output = output & Globals.FIELD_SEPARATOR & "PROJECT_ID=" & dataRow.Item("PROJECT_ID")

                output = output & Globals.FIELD_SEPARATOR & "ADD_BY=" & dataRow.Item("ADD_BY")
                output = output & Globals.FIELD_SEPARATOR & "DATE_ADD=" & dataRow.Item("DATE_ADD")
                output = output & Globals.FIELD_SEPARATOR & "TIME_ADD=" & dataRow.Item("TIME_ADD")
                output = output & Globals.FIELD_SEPARATOR & "DATE_UPDATE=" & dataRow.Item("DATE_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "TIME_UPDATE=" & dataRow.Item("TIME_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "UPDATE_BY=" & dataRow.Item("UPDATE_BY")
                output = output & Globals.FIELD_SEPARATOR & "PDA_CODE=" & dataRow.Item("PDA_CODE")
            Next

        End If

        Return output
    End Function

    Public Function processPdaCouponSystemData(ByVal projectId As String) As String
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""

        SQL = "SELECT * FROM eqam_coupon_system"
        'SQL = "SELECT * FROM eqam_coupon WHERE PROJECT_ID = @PROJECT_ID"
        'paramList.Add("@PROJECT_ID", projectId)

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                output = output & Globals.RECORD_SEPARATOR & "SYSTEM_ID=" & dataRow.Item("SYSTEM_ID")
                If (IsDBNull(dataRow.Item("S_SYSTEM_ID")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "S_SYSTEM_ID=" & dataRow.Item("S_SYSTEM_ID")
                End If
                'output = output & Globals.RECORD_SEPARATOR & "S_SYSTEM_ID=" & dataRow.Item("S_SYSTEM_ID"))                                
                output = output & Globals.FIELD_SEPARATOR & "COUPON_BARCODE=" & dataRow.Item("COUPON_BARCODE")
                output = output & Globals.FIELD_SEPARATOR & "SYSTEM_TYPE_ID=" & dataRow.Item("SYSTEM_TYPE_ID")
                output = output & Globals.FIELD_SEPARATOR & "ADD_BY=" & dataRow.Item("ADD_BY")
                output = output & Globals.FIELD_SEPARATOR & "DATE_ADD=" & dataRow.Item("DATE_ADD")
                output = output & Globals.FIELD_SEPARATOR & "TIME_ADD=" & dataRow.Item("TIME_ADD")
                output = output & Globals.FIELD_SEPARATOR & "DATE_UPDATE=" & dataRow.Item("DATE_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "TIME_UPDATE=" & dataRow.Item("TIME_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "UPDATE_BY=" & dataRow.Item("UPDATE_BY")
                output = output & Globals.FIELD_SEPARATOR & "PDA_CODE=" & dataRow.Item("PDA_CODE")
            Next

        End If

        Return output
    End Function

    Public Function getCouponCode(ByVal couponId As Integer) As String
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""


        SQL = "SELECT * FROM eqam_coupon where COUPON_ID = " & couponId

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            Dim dataRow As DataRow = dtResult.Rows(0)
            output = dataRow.Item("COUPON_CODE")
        End If

        Return output
    End Function

    Public Function processPdaCouponData(ByVal couponId As String) As String
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""

        SQL = "SELECT * FROM eqam_coupon"
        'SQL = "SELECT * FROM eqam_coupon WHERE PROJECT_ID = @PROJECT_ID"
        'paramList.Add("@PROJECT_ID", projectId)

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                output = output & Globals.RECORD_SEPARATOR & "COUPON_ID=" & dataRow.Item("COUPON_ID")
                If (IsDBNull(dataRow.Item("S_COUPON_ID")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "S_COUPON_ID=" & dataRow.Item("S_COUPON_ID")
                End If

                'If (IsDBNull(dataRow.Item("S_COUPON_ID")) = False) Then
                '    output = output & Globals.FIELD_SEPARATOR & "PARENT_COUPON_ID=" & dataRow.Item("PARENT_COUPON_ID")
                '    output = output & Globals.FIELD_SEPARATOR & "PARENT_COUPON_CODE=" & getCouponCode(dataRow.Item("PARENT_COUPON_ID"))
                'Else
                '    output = output & Globals.FIELD_SEPARATOR & "PARENT_COUPON_ID="
                '    output = output & Globals.FIELD_SEPARATOR & "PARENT_COUPON_CODE="
                'End If

                output = output & Globals.FIELD_SEPARATOR & "COUPON_CODE=" & dataRow.Item("COUPON_CODE")
                output = output & Globals.FIELD_SEPARATOR & "COUPON_TYPE=" & dataRow.Item("COUPON_TYPE")
                output = output & Globals.FIELD_SEPARATOR & "BARCODE=" & dataRow.Item("BARCODE")

                If (IsDBNull(dataRow.Item("PARENT_COUPON_BARCODE")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "PARENT_COUPON_BARCODE=" & dataRow.Item("PARENT_COUPON_BARCODE")
                Else
                    output = output & Globals.FIELD_SEPARATOR & "PARENT_COUPON_BARCODE="
                End If


                output = output & Globals.FIELD_SEPARATOR & "WELDER_USER_ID=" & dataRow.Item("WELDER_USER_ID")
                output = output & Globals.FIELD_SEPARATOR & "PIPE_TUBE=" & dataRow.Item("PIPE_TUBE")
                output = output & Globals.FIELD_SEPARATOR & "IS_COAX=" & dataRow.Item("IS_COAX")
                output = output & Globals.FIELD_SEPARATOR & "COAX=" & dataRow.Item("COAX")
                output = output & Globals.FIELD_SEPARATOR & "PROJECT_ID=" & dataRow.Item("PROJECT_ID")

                output = output & Globals.FIELD_SEPARATOR & "WELD_MACHINE_ID=" & dataRow.Item("WELD_MACHINE_ID")
                output = output & Globals.FIELD_SEPARATOR & "WELD_MACHINE_NAME=" & dataRow.Item("WELD_MACHINE_NAME")
                output = output & Globals.FIELD_SEPARATOR & "MATERIAL=" & dataRow.Item("MATERIAL")
                output = output & Globals.FIELD_SEPARATOR & "SIZE=" & dataRow.Item("SIZE")
                output = output & Globals.FIELD_SEPARATOR & "THICKNESS=" & dataRow.Item("THICKNESS")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_ID_1=" & dataRow.Item("HEAT_NUMBER_ID_1")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_NAME_1=" & dataRow.Item("HEAT_NUMBER_NAME_1")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_ID_2=" & dataRow.Item("HEAT_NUMBER_ID_2")
                output = output & Globals.FIELD_SEPARATOR & "HEAT_NUMBER_NAME_2=" & dataRow.Item("HEAT_NUMBER_NAME_2")
                output = output & Globals.FIELD_SEPARATOR & "STATUS_CODE=" & dataRow.Item("STATUS_CODE")
                If (IsDBNull(dataRow.Item("REJECT_REASON")) = False) Then
                    output = output & Globals.FIELD_SEPARATOR & "REJECT_REASON=" & dataRow.Item("REJECT_REASON")
                Else
                    output = output & Globals.FIELD_SEPARATOR & "REJECT_REASON="
                End If

                output = output & Globals.FIELD_SEPARATOR & "REMARKS=" & dataRow.Item("REMARKS")

                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_CODE_1=" & dataRow.Item("JOINT_TYPE_CODE_1")
                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_NAME_1=" & dataRow.Item("JOINT_TYPE_NAME_1")
                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_CODE_2=" & dataRow.Item("JOINT_TYPE_CODE_2")
                output = output & Globals.FIELD_SEPARATOR & "JOINT_TYPE_NAME_2=" & dataRow.Item("JOINT_TYPE_NAME_2")

                output = output & Globals.FIELD_SEPARATOR & "PDA_CODE=" & dataRow.Item("PDA_CODE")
                output = output & Globals.FIELD_SEPARATOR & "ADD_BY=" & dataRow.Item("ADD_BY")
                output = output & Globals.FIELD_SEPARATOR & "DATE_ADD=" & dataRow.Item("DATE_ADD")
                output = output & Globals.FIELD_SEPARATOR & "TIME_ADD=" & dataRow.Item("TIME_ADD")
                output = output & Globals.FIELD_SEPARATOR & "DATE_UPDATE=" & dataRow.Item("DATE_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "TIME_UPDATE=" & dataRow.Item("TIME_UPDATE")
                output = output & Globals.FIELD_SEPARATOR & "UPDATE_BY=" & dataRow.Item("UPDATE_BY")
            Next

        End If

        Return output
    End Function

    Public Function syncWelderSize(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""

        SQL = "SELECT * FROM eqam_weld_size WHERE WELD_SIZE_ID = @WELD_SIZE_ID"
        paramList.Add("@WELD_SIZE_ID", hashtable("id"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_weld_size SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY, WELDER_ID = @WELDER_ID, PROJECT_ID = @PROJECT_ID, SIZE = @SIZE" & _
                  " WHERE WELD_SIZE_ID = @WELD_SIZE_ID"
        Else
            SQL = "INSERT INTO eqam_weld_size(WELD_SIZE_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, WELDER_ID, PROJECT_ID, SIZE) " & _
                                " VALUES (@WELD_SIZE_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @WELDER_ID, @PROJECT_ID, @SIZE)"
        End If

        'first line        
        'paramList = New Hashtable()
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("statusCode"))
        'sec line
        'paramList.Add("@WELD_SIZE_ID", hashtable("id"))
        paramList.Add("@WELDER_ID", hashtable("welderId"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))
        paramList.Add("@SIZE", hashtable("weldSize"))
        txtLog.Text = txtLog.Text & hashtable("id")

        Return ExecuteSQL(SQL, paramList)
    End Function
    Public Function syncWeldlogDetail(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "INSERT INTO eqam_weldlog_detail(ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, ZONE_ID, ZONE" & _
                                ", S_WELDLOG_DETAIL_ID, BARCODE, BARCODE_REF, SEQ, COUPON_CODE, COUPON_TYPE, WELDER_USER_ID, WELD_DATE " & _
                                ", WELD_TIME, QC_USER_ID, QC_DATE, QC_TIME, QC_STATUS, REJECT_REASON, REPLACEMENT_ID " & _
                                ", REJECT_BARCODE, REPLACE_BARCODE, REMARK, STATUS_CODE, SYSTEM_TYPE_ID, SYSTEM_TYPE_NAME, HEAT_NUMBER_ID_1, HEAT_NUMBER_NAME_1 " & _
                                ", HEAT_NUMBER_ID_2, HEAT_NUMBER_NAME_2, JOINT_TYPE_CODE_1, JOINT_TYPE_NAME_1, JOINT_TYPE_CODE_2, JOINT_TYPE_NAME_2, PDA_CODE) " & _
                                " VALUES (@ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @ZONE_ID, @ZONE" & _
                                ", @S_WELDLOG_DETAIL_ID, @BARCODE, @BARCODE_REF, @SEQ, @COUPON_CODE, @COUPON_TYPE, @WELDER_USER_ID, @WELD_DATE " & _
                                ", @WELD_TIME, @QC_USER_ID, @QC_DATE, @QC_TIME, @QC_STATUS, @REJECT_REASON, @REPLACEMENT_ID " & _
                                ", @REJECT_BARCODE, @REPLACE_BARCODE, @REMARK, @STATUS_CODE, @SYSTEM_TYPE_ID, @SYSTEM_TYPE_NAME, @HEAT_NUMBER_ID_1, @HEAT_NUMBER_NAME_1 " & _
                                ", @HEAT_NUMBER_ID_2, @HEAT_NUMBER_NAME_2, @JOINT_TYPE_CODE_1, @JOINT_TYPE_NAME_1, @JOINT_TYPE_CODE_2, @JOINT_TYPE_NAME_2, @PDA_CODE)"

        'first line        
        paramList.Add("@ADD_BY", hashtable("pdaAddBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("pdaUpdateBy"))

        'sec line
        paramList.Add("@S_WELDLOG_DETAIL_ID", hashtable("weldLogId"))
        paramList.Add("@BARCODE", hashtable("barcode"))
        paramList.Add("@BARCODE_REF", hashtable("barcodeRefer"))
        paramList.Add("@SEQ", hashtable("seq"))
        paramList.Add("@COUPON_CODE", hashtable("couponNo"))
        paramList.Add("@COUPON_TYPE", hashtable("couponType"))
        paramList.Add("@WELDER_USER_ID", hashtable("welderUserId"))
        paramList.Add("@WELD_DATE", hashtable("pdaWeldDateDATE"))

        'third line
        paramList.Add("@WELD_TIME", hashtable("pdaWeldDateTIME"))
        paramList.Add("@QC_USER_ID", "")
        paramList.Add("@QC_DATE", 0)
        paramList.Add("@QC_TIME", 0)
        paramList.Add("@QC_STATUS", "")
        paramList.Add("@REJECT_REASON", hashtable("rejectReasonDesc"))

        paramList.Add("@REPLACEMENT_ID", 0)

        'forth line
        paramList.Add("@REJECT_BARCODE", hashtable("rejectBarcode"))
        paramList.Add("@REPLACE_BARCODE", hashtable("replacementBarcode"))

        paramList.Add("@REMARK", hashtable("remarks"))
        paramList.Add("@STATUS_CODE", hashtable("statusCode"))
        paramList.Add("@SYSTEM_TYPE_ID", hashtable("systemTypeId"))
        paramList.Add("@SYSTEM_TYPE_NAME", hashtable("systemTypeName"))
        paramList.Add("@HEAT_NUMBER_ID_1", hashtable("heatNumber1Id"))
        paramList.Add("@HEAT_NUMBER_NAME_1", hashtable("heatNumber1Name"))
        paramList.Add("@ZONE_ID", hashtable("areaId"))
        paramList.Add("@ZONE", hashtable("areaName"))

        'fifth line
        paramList.Add("@HEAT_NUMBER_ID_2", hashtable("heatNumber2Id"))
        paramList.Add("@HEAT_NUMBER_NAME_2", hashtable("heatNumber2Name"))
        paramList.Add("@JOINT_TYPE_CODE_1", hashtable("jointType1Id"))
        paramList.Add("@JOINT_TYPE_NAME_1", hashtable("jointType1Name"))
        paramList.Add("@JOINT_TYPE_CODE_2", hashtable("jointType2Id"))
        paramList.Add("@JOINT_TYPE_NAME_2", hashtable("jointType2Name"))
        paramList.Add("@PDA_CODE", hashtable("pdaCode"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncCoupon(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "INSERT INTO eqam_coupon(ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY" & _
                                ", S_COUPON_ID, COUPON_CODE, COUPON_TYPE, WELDER_USER_ID, PIPE_TUBE, IS_COAX, COAX, PROJECT_ID " & _
                                ", WELD_MACHINE_ID, WELD_MACHINE_NAME, MATERIAL, SIZE, THICKNESS, HEAT_NUMBER_ID_1, HEAT_NUMBER_NAME_1, HEAT_NUMBER_ID_2, HEAT_NUMBER_NAME_2 " & _
                                ", STATUS_CODE, REJECT_REASON, REMARKS, PARENT_COUPON_BARCODE, BARCODE, JOINT_TYPE_CODE_1, JOINT_TYPE_NAME_1, JOINT_TYPE_CODE_2, JOINT_TYPE_NAME_2, PDA_CODE) " & _
                                " VALUES (@ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY" & _
                                ", @S_COUPON_ID, @COUPON_CODE, @COUPON_TYPE, @WELDER_USER_ID, @PIPE_TUBE, @IS_COAX, @COAX, @PROJECT_ID " & _
                                ", @WELD_MACHINE_ID, @WELD_MACHINE_NAME, @MATERIAL, @SIZE, @THICKNESS, @HEAT_NUMBER_ID_1, @HEAT_NUMBER_NAME_1, @HEAT_NUMBER_ID_2, @HEAT_NUMBER_NAME_2 " & _
                                ", @STATUS_CODE, @REJECT_REASON, @REMARKS, @PARENT_COUPON_BARCODE, @BARCODE, @JOINT_TYPE_CODE_1, @JOINT_TYPE_NAME_1, @JOINT_TYPE_CODE_2, @JOINT_TYPE_NAME_2, @PDA_CODE) "

        'first line        
        paramList.Add("@ADD_BY", hashtable("pdaAddBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("pdaUpdateBy"))

        'sec line
        paramList.Add("@S_COUPON_ID", hashtable("weldLogId"))
        paramList.Add("@COUPON_CODE", hashtable("couponNo"))
        paramList.Add("@COUPON_TYPE", hashtable("couponType"))
        paramList.Add("@WELDER_USER_ID", hashtable("welderUserId"))
        paramList.Add("@PIPE_TUBE", "TUBE")
        paramList.Add("@IS_COAX", hashtable("isCoax"))
        paramList.Add("@COAX", hashtable("coaxType"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))

        'third line
        paramList.Add("@WELD_MACHINE_ID", hashtable("weldMachineId"))
        paramList.Add("@WELD_MACHINE_NAME", hashtable("weldMachineName"))
        paramList.Add("@MATERIAL", hashtable("material"))
        paramList.Add("@SIZE", hashtable("size"))
        paramList.Add("@THICKNESS", hashtable("thickness"))
        paramList.Add("@HEAT_NUMBER_ID_1", hashtable("heatNumber1Id"))
        paramList.Add("@HEAT_NUMBER_NAME_1", hashtable("heatNumber1Name"))
        paramList.Add("@HEAT_NUMBER_ID_2", hashtable("heatNumber2Id"))
        paramList.Add("@HEAT_NUMBER_NAME_2", hashtable("heatNumber2Name"))

        'forth line
        paramList.Add("@STATUS_CODE", hashtable("statusCode"))
        paramList.Add("@REJECT_REASON", hashtable("rejectReasonDesc"))
        paramList.Add("@REMARKS", hashtable("remarks"))
        paramList.Add("@PARENT_COUPON_BARCODE", hashtable("parentCouponBarcode"))
        paramList.Add("@BARCODE", hashtable("barcode"))
        paramList.Add("@JOINT_TYPE_CODE_1", hashtable("jointType1Id"))
        paramList.Add("@JOINT_TYPE_NAME_1", hashtable("jointType1Name"))
        paramList.Add("@JOINT_TYPE_CODE_2", hashtable("jointType2Id"))
        paramList.Add("@JOINT_TYPE_NAME_2", hashtable("jointType2Name"))
        paramList.Add("@PDA_CODE", hashtable("pdaCode"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function getParentCouponCodeByCouponNo(ByVal couponCode As String) As Integer
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT COUPON_ID FROM eqam_coupon WHERE COUPON_CODE = @COUPON_CODE AND COUPON_TYPE = @COUPON_TYPE"
        paramList.Add("@COUPON_CODE", couponCode)
        paramList.Add("@COUPON_TYPE", "I")

        If (couponCode <> "") Then
            dtResult = LoadData(SQL, paramList)

            If dtResult.Rows.Count > 0 Then
                For Each dataRow As DataRow In dtResult.Rows
                    output = dataRow.Item("COUPON_ID")
                Next
            Else
                output = "0"
            End If
        Else
            output = "0"
        End If
        
        Return output
    End Function

    Public Function deleteAllWeldMachine(ByVal projectId As String) As Boolean
        Dim paramList As New Hashtable()

        Dim SQL As String = "DELETE FROM eqam_weld_machine WHERE PROJECT_ID = @PROJECT_ID"
        paramList.Add("@PROJECT_ID", projectId)

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function deleteAllCoupon(ByVal projectId As String) As Boolean
        Dim paramList As New Hashtable()

        Dim SQL As String = "DELETE FROM eqam_coupon WHERE PROJECT_ID = @PROJECT_ID"
        paramList.Add("@PROJECT_ID", projectId)

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function deleteAllWeldSeq(ByVal projectId As String) As Boolean
        Dim paramList As New Hashtable()

        Dim SQL As String = "DELETE FROM eqam_weld_seq WHERE PROJECT_ID = @PROJECT_ID"
        paramList.Add("@PROJECT_ID", projectId)

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function deleteAllWeldReplacement(ByVal projectId As String) As Boolean
        Dim paramList As New Hashtable()

        Dim SQL As String = "DELETE FROM eqam_weld_replacement WHERE PROJECT_ID = @PROJECT_ID"
        paramList.Add("@PROJECT_ID", projectId)

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function deleteAllWeldlogDetail(ByVal projectId As String) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT COUPON_CODE FROM eqam_coupon WHERE PROJECT_ID = @PROJECT_ID GROUP BY COUPON_CODE"
        paramList.Add("@PROJECT_ID", projectId)

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows
                SQL = "DELETE FROM eqam_weldlog_detail WHERE COUPON_CODE = @COUPON_CODE"
                paramList.Add("@COUPON_CODE", dataRow.Item("COUPON_CODE"))

                ExecuteSQL(SQL, paramList)
            Next            
        End If

        Return True
    End Function

    Public Function deleteAllProjectWelder(ByVal projectId As String) As Boolean
        Dim paramList As New Hashtable()

        Dim SQL As String = "DELETE FROM eqam_project_welder_mapping WHERE PROJECT_ID = @PROJECT_ID"
        paramList.Add("@PROJECT_ID", projectId)

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncProjectWelder(ByVal hashtable As Hashtable) As Boolean
        Dim paramList As New Hashtable()

        Dim dtResult As New DataTable
        Dim output As String = ""

        Dim SQL As String = "INSERT INTO eqam_project_welder_mapping (PROJECT_ID, WELDER_ID) " & _
                                " VALUES (@PROJECT_ID, @WELDER_ID)"

        paramList.Add("@PROJECT_ID", hashtable("projectId"))
        paramList.Add("@WELDER_ID", hashtable("welderId"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncWeldMachine(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim SQL As String = ""
        Dim output As String = ""

        SQL = "SELECT * FROM eqam_weld_machine WHERE PROJECT_WELD_MACHINE_ID = @PROJECT_WELD_MACHINE_ID"
        paramList.Add("@PROJECT_WELD_MACHINE_ID", hashtable("projectWeldMachineId"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_weld_machine SET WELD_MACHINE_ID = @WELD_MACHINE_ID, ADD_BY = @ADD_BY, DATE_ADD = @DATE_ADD" & _
                        ", TIME_ADD = @TIME_ADD, DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                        ", SERIAL_NUMBER = @SERIAL_NUMBER, PROJECT_ID = @PROJECT_ID, WELD_MACHINE_MODEL = @WELD_MACHINE_MODEL, CALIBRATION_DATE_ADD = @CALIBRATION_DATE_ADD, CALIBRATION_TIME_ADD = @CALIBRATION_TIME_ADD" & _
                  " WHERE PROJECT_WELD_MACHINE_ID = @PROJECT_WELD_MACHINE_ID"
        Else
            SQL = "INSERT INTO eqam_weld_machine(PROJECT_WELD_MACHINE_ID, WELD_MACHINE_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, SERIAL_NUMBER, PROJECT_ID, WELD_MACHINE_MODEL, CALIBRATION_DATE_ADD, CALIBRATION_TIME_ADD) " & _
                                " VALUES (@PROJECT_WELD_MACHINE_ID, @WELD_MACHINE_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @SERIAL_NUMBER, @PROJECT_ID, @WELD_MACHINE_MODEL, @CALIBRATION_DATE_ADD, @CALIBRATION_TIME_ADD)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS", hashtable("status"))

        'sec line
        'paramList.Add("@PROJECT_WELD_MACHINE_ID", hashtable("projectWeldMachineId"))
        paramList.Add("@WELD_MACHINE_ID", hashtable("weldMachineId"))
        paramList.Add("@SERIAL_NUMBER", hashtable("serialNumber"))
        paramList.Add("@WELD_MACHINE_MODEL", hashtable("weldMachineModel"))
        paramList.Add("@CALIBRATION_DATE_ADD", hashtable("calibrationDateDATE"))
        paramList.Add("@CALIBRATION_TIME_ADD", hashtable("calibrationDateTIME"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncWeldSeq(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "INSERT INTO eqam_weld_seq(ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY" & _
                                ", S_SEQ_ID, PROJECT_ID, ZONE, SEQ, BARCODE, PDA_CODE) " & _
                                " VALUES (@ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY" & _
                                ", @S_SEQ_ID, @PROJECT_ID, @ZONE, @SEQ, @BARCODE, @PDA_CODE)"

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))

        'sec line
        paramList.Add("@S_SEQ_ID", hashtable("id"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))
        paramList.Add("@ZONE", hashtable("area"))
        paramList.Add("@SEQ", hashtable("seq"))
        paramList.Add("@BARCODE", hashtable("barcode"))
        paramList.Add("@PDA_CODE", hashtable("pdaCode"))

        Return ExecuteSQL(SQL, paramList)
    End Function
    Public Function syncWeldReplacement(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "INSERT INTO eqam_weld_replacement(ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY" & _
                                ", S_REPLACEMENT_ID, REJECT_BARCODE, REPLACE_BARCODE, PROJECT_ID, PDA_CODE) " & _
                                " VALUES (@ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY" & _
                                ", @S_REPLACEMENT_ID, @REJECT_BARCODE, @REPLACE_BARCODE, @PROJECT_ID, @PDA_CODE)"

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))

        'sec line
        paramList.Add("@S_REPLACEMENT_ID", hashtable("weldPlacementId"))
        paramList.Add("@REJECT_BARCODE", hashtable("rejectBarcode"))
        paramList.Add("@REPLACE_BARCODE", hashtable("replacementBarcode"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))
        paramList.Add("@PDA_CODE", hashtable("pdaCode"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function getWeldlogIdByBarcode(ByVal barcode As String) As Integer
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT WELDLOG_DETAIL_ID FROM eqam_weldlog_detail WHERE BARCODE = @BARCODE"
        paramList.Add("@BARCODE", barcode)

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            For Each dataRow As DataRow In dtResult.Rows               
                output = dataRow.Item("WELDLOG_DETAIL_ID")
            Next
        End If

        Return output
    End Function

    Public Function syncArea(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_zone WHERE ZONE_ID = @ZONE_ID"
        paramList.Add("@ZONE_ID", hashtable("id"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_zone SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY, ZONE = @ZONE, PROJECT_ID = @PROJECT_ID, SEQ = @SEQ" & _
                  " WHERE ZONE_ID = @ZONE_ID"
        Else
            SQL = "INSERT INTO eqam_zone(ZONE_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, ZONE, PROJECT_ID, SEQ) " & _
                                " VALUES (@ZONE_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @ZONE, @PROJECT_ID, @SEQ)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("statusCode"))
        'sec line
        'paramList.Add("@ZONE_ID", hashtable("id"))
        paramList.Add("@ZONE", hashtable("areaName"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))
        paramList.Add("@SEQ", hashtable("seq"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncRejectReason(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_reject_reason WHERE REASON_ID = @REASON_ID"
        paramList.Add("@REASON_ID", hashtable("id"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_reject_reason SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " WHERE REASON_ID = @REASON_ID"

        Else
            SQL = "INSERT INTO eqam_reject_reason(REASON_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, REASON) " & _
                                " VALUES (@REASON_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @REASON)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("statusCode"))
        'sec line
        'paramList.Add("@REASON_ID", hashtable("id"))
        paramList.Add("@REASON", hashtable("reason"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncJointType(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_joint_type WHERE JOINT_TYPE_CODE = @JOINT_TYPE_CODE"
        paramList.Add("@JOINT_TYPE_CODE", hashtable("jointTypeCode"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_joint_type SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,STATUS_CODE = @STATUS_CODE, JOINT_TYPE_NAME = @JOINT_TYPE_NAME" & _
                  " WHERE JOINT_TYPE_CODE = @JOINT_TYPE_CODE"
        Else
            SQL = "INSERT INTO eqam_joint_type(JOINT_TYPE_CODE, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE, JOINT_TYPE_NAME) " & _
                                " VALUES (@JOINT_TYPE_CODE, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @STATUS_CODE, @JOINT_TYPE_NAME)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("status"))
        'sec line
        'paramList.Add("@JOINT_TYPE_CODE", hashtable("jointTypeCode"))
        paramList.Add("@JOINT_TYPE_NAME", hashtable("jointTypeName"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncHeatNumber(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_heat_number WHERE HEAT_NUMBER_ID = @HEAT_NUMBER_ID"
        paramList.Add("@HEAT_NUMBER_ID", hashtable("id"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_heat_number SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,STATUS_CODE = @STATUS_CODE, PROJECT_ID = @PROJECT_ID, HEAT_NUMBER_NAME = @HEAT_NUMBER_NAME" & _
                  " WHERE HEAT_NUMBER_ID = @HEAT_NUMBER_ID"

        Else
            SQL = "INSERT INTO eqam_heat_number(HEAT_NUMBER_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE, PROJECT_ID, HEAT_NUMBER_NAME) " & _
                                " VALUES (@HEAT_NUMBER_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @STATUS_CODE, @PROJECT_ID, @HEAT_NUMBER_NAME)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("status"))
        'sec line
        'paramList.Add("@HEAT_NUMBER_ID", hashtable("id"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))
        paramList.Add("@HEAT_NUMBER_NAME", hashtable("heatNumberDesc"))
        'paramList.Add("@WELD_SIZE", hashtable("weldSize"))
        'paramList.Add("@JOINT_TYPE_NAME", hashtable("jointTypeName"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncSystemType(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_system_type WHERE SYSTEM_TYPE_ID = @SYSTEM_TYPE_ID"
        paramList.Add("@SYSTEM_TYPE_ID", hashtable("id"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_system_type SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,STATUS_CODE = @STATUS_CODE, PROJECT_ID = @PROJECT_ID, SYSTEM_TYPE_NAME = @SYSTEM_TYPE_NAME, DRAWING_NUMBER = @DRAWING_NUMBER " & _
                  " WHERE SYSTEM_TYPE_ID = @SYSTEM_TYPE_ID"
        Else
            SQL = "INSERT INTO eqam_system_type(SYSTEM_TYPE_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE, PROJECT_ID, SYSTEM_TYPE_NAME, DRAWING_NUMBER) " & _
                                " VALUES (@SYSTEM_TYPE_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @STATUS_CODE, @PROJECT_ID, @SYSTEM_TYPE_NAME, @DRAWING_NUMBER)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("status"))
        paramList.Add("@DRAWING_NUMBER", hashtable("drawingNumber"))
        'sec line
        'paramList.Add("@SYSTEM_TYPE_ID", hashtable("id"))
        paramList.Add("@PROJECT_ID", hashtable("projectId"))
        paramList.Add("@SYSTEM_TYPE_NAME", hashtable("systemTypeName"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncTubeType(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_tube_type WHERE TUBE_TYPE_ID = @TUBE_TYPE_ID"
        paramList.Add("@TUBE_TYPE_ID", hashtable("id"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_tube_type SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,STATUS_CODE = @STATUS_CODE, MATERIAL = @MATERIAL, SIZE = @SIZE, THICKNESS = @THICKNESS " & _
                  " WHERE TUBE_TYPE_ID = @TUBE_TYPE_ID"

        Else
            SQL = "INSERT INTO eqam_tube_type(TUBE_TYPE_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE, MATERIAL, SIZE, THICKNESS) " & _
                                " VALUES (@TUBE_TYPE_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @STATUS_CODE, @MATERIAL, @SIZE, @THICKNESS)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("statusCode"))
        'sec line
        'paramList.Add("@TUBE_TYPE_ID", hashtable("id"))
        paramList.Add("@MATERIAL", hashtable("material"))
        paramList.Add("@SIZE", hashtable("size"))
        paramList.Add("@THICKNESS", hashtable("thickness"))


        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncMaterial(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_material WHERE MATERIAL = @MATERIAL"
        paramList.Add("@MATERIAL", hashtable("material"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_material SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,STATUS_CODE = @STATUS_CODE " & _
                  " WHERE MATERIAL = @MATERIAL"
        Else
            SQL = "INSERT INTO eqam_material(MATERIAL, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, STATUS_CODE) " & _
                                " VALUES (@MATERIAL, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @STATUS_CODE)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("status"))
        'sec line
        'paramList.Add("@MATERIAL", hashtable("material"))

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncProject(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_project WHERE PROJECT_ID = @PROJECT_ID"
        paramList.Add("@PROJECT_ID", hashtable("id"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_project SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,PROJECT_NAME = @PROJECT_NAME, SUPERVISOR_NAME = @SUPERVISOR_NAME" & _
                  " ,SUPERVISOR_ID = @SUPERVISOR_ID, STATUS_CODE = @STATUS_CODE " & _
                  " WHERE PROJECT_ID = @PROJECT_ID"

        Else
            SQL = "INSERT INTO eqam_project(PROJECT_ID, SUPERVISOR_NAME, SUPERVISOR_ID, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, PROJECT_NAME, STATUS_CODE) " & _
                                " VALUES (@PROJECT_ID, @SUPERVISOR_NAME, @SUPERVISOR_ID, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @PROJECT_NAME, @STATUS_CODE)"
        End If

        'first line        
        paramList.Add("@ADD_BY", hashtable("addBy"))
        paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
        paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
        paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
        paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
        paramList.Add("@UPDATE_BY", hashtable("updateBy"))
        paramList.Add("@STATUS_CODE", hashtable("statusCode"))
        'sec line
        'paramList.Add("@PROJECT_ID", hashtable("id"))
        paramList.Add("@PROJECT_NAME", hashtable("projectName"))
        paramList.Add("@SUPERVISOR_NAME", hashtable("supervisorName"))
        paramList.Add("@SUPERVISOR_ID", hashtable("supervisorId"))

        Return ExecuteSQL(SQL, paramList)
    End Function
    Public Function syncEngineer(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""

        Dim SQL As String = "SELECT * FROM eqam_user WHERE USER_ID = @ENGINEER_ID"
        paramList.Add("@ENGINEER_ID", hashtable("engineerId"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_user SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,USER_FULL_NAME = @USER_FULL_NAME, USER_ROLE = @USER_ROLE" & _
                  " ,USER_NAME = @USER_NAME, USER_PASSWORD = @USER_PASSWORD, STATUS_CODE = @STATUS_CODE " & _
                  " WHERE USER_ID = @USER_ID"

            'first line        
            paramList.Add("@ADD_BY", hashtable("addBy"))
            paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
            paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
            paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
            paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
            paramList.Add("@UPDATE_BY", hashtable("updateBy"))
            paramList.Add("@STATUS_CODE", hashtable("statusCode"))
            'sec line
            paramList.Add("@USER_ID", hashtable("engineerId"))
            paramList.Add("@USER_FULL_NAME", hashtable("engineerName"))
            paramList.Add("@USER_ROLE", "ENGINEER")
            paramList.Add("@USER_NAME", hashtable("userName"))
            paramList.Add("@USER_PASSWORD", hashtable("pdaPassword"))

        Else
            SQL = "INSERT INTO eqam_user(USER_ID, USER_FULL_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, USER_ROLE, USER_NAME, USER_PASSWORD, STATUS_CODE) " & _
                            " VALUES (@USER_ID, @USER_FULL_NAME, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @USER_ROLE, @USER_NAME, @USER_PASSWORD, @STATUS_CODE)"
            'first line            
            paramList.Add("@ADD_BY", hashtable("addBy"))
            paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
            paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
            paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
            paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
            paramList.Add("@UPDATE_BY", hashtable("updateBy"))
            paramList.Add("@STATUS_CODE", hashtable("statusCode"))
            'sec line
            paramList.Add("@USER_ID", hashtable("engineerId"))
            paramList.Add("@USER_FULL_NAME", hashtable("engineerName"))
            paramList.Add("@USER_ROLE", "ENGINEER")
            paramList.Add("@USER_NAME", hashtable("userName"))
            paramList.Add("@USER_PASSWORD", hashtable("pdaPassword"))
        End If

        Return ExecuteSQL(SQL, paramList)
    End Function

    Public Function syncWelder(ByVal hashtable As Hashtable) As Boolean
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim output As String = ""
        Dim success As Boolean = True

        Dim SQL As String = "SELECT * FROM eqam_welder WHERE WELDER_ID = @WELDER_ID"
        paramList.Add("@WELDER_ID", hashtable("welderId"))

        dtResult = LoadData(SQL, paramList)

        If dtResult.Rows.Count > 0 Then
            SQL = "UPDATE eqam_welder SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,WELDER_COMPANY_NAME = @WELDER_COMPANY_NAME, WELDER_COMPANY_CODE = @WELDER_COMPANY_CODE" & _
                  " ,STATUS_CODE = @STATUS_CODE " & _
                  " WHERE WELDER_ID = @WELDER_ID"

            'first line        
            paramList.Add("@ADD_BY", hashtable("addBy"))
            paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
            paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
            paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
            paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
            paramList.Add("@UPDATE_BY", hashtable("updateBy"))
            paramList.Add("@STATUS_CODE", hashtable("statusCode"))
            'sec line
            'paramList.Add("@WELDER_ID", hashtable("welderId"))
            paramList.Add("@WELDER_NAME", hashtable("welderName"))
            paramList.Add("@WELDER_COMPANY_CODE", hashtable("welderCompanyCode"))
            paramList.Add("@WELDER_COMPANY_NAME", hashtable("welderCompanyName"))

            If (ExecuteSQL(SQL, paramList)) Then
                SQL = "UPDATE eqam_user SET DATE_UPDATE = @DATE_UPDATE, TIME_UPDATE = @TIME_UPDATE, UPDATE_BY = @UPDATE_BY" & _
                  " ,DATE_ADD = @DATE_ADD, TIME_ADD = @TIME_ADD, ADD_BY = @ADD_BY" & _
                  " ,USER_FULL_NAME = @USER_FULL_NAME, USER_ROLE = @USER_ROLE" & _
                  " ,USER_NAME = @USER_NAME, USER_PASSWORD = @USER_PASSWORD, STATUS_CODE = @STATUS_CODE " & _
                  " WHERE USER_ID = @USER_ID"

                'first line        
                'paramList.Add("@ADD_BY", hashtable("addBy"))
                'paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
                'paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
                'paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
                'paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
                'paramList.Add("@UPDATE_BY", hashtable("updateBy"))
                'paramList.Add("@STATUS_CODE", hashtable("statusCode"))
                'sec line

                'paramList = New Hashtable()

                paramList.Add("@USER_ID", hashtable("welderId"))
                paramList.Add("@USER_FULL_NAME", hashtable("welderName"))
                paramList.Add("@USER_ROLE", "WELDER")
                paramList.Add("@USER_NAME", hashtable("userName"))
                paramList.Add("@USER_PASSWORD", hashtable("pdaPassword"))

                success = ExecuteSQL(SQL, paramList)
            Else
                success = False
            End If
        Else
            SQL = "INSERT INTO eqam_welder(WELDER_ID, WELDER_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, WELDER_COMPANY_CODE, WELDER_COMPANY_NAME, STATUS_CODE) " & _
                                " VALUES (@WELDER_ID, @WELDER_NAME, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @WELDER_COMPANY_CODE, @WELDER_COMPANY_NAME, @STATUS_CODE)"

            'first line        
            paramList.Add("@ADD_BY", hashtable("addBy"))
            paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
            paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
            paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
            paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
            paramList.Add("@UPDATE_BY", hashtable("updateBy"))
            paramList.Add("@STATUS_CODE", hashtable("statusCode"))
            'sec line
            'paramList.Add("@WELDER_ID", hashtable("welderId"))
            paramList.Add("@WELDER_NAME", hashtable("welderName"))
            paramList.Add("@WELDER_COMPANY_CODE", hashtable("welderCompanyCode"))
            paramList.Add("@WELDER_COMPANY_NAME", hashtable("welderCompanyName"))

            If (ExecuteSQL(SQL, paramList)) Then
                SQL = "INSERT INTO eqam_user(USER_ID, USER_FULL_NAME, ADD_BY, DATE_ADD, TIME_ADD, DATE_UPDATE, TIME_UPDATE, UPDATE_BY, USER_ROLE, USER_NAME, USER_PASSWORD, STATUS_CODE) " & _
                            " VALUES (@USER_ID, @USER_FULL_NAME, @ADD_BY, @DATE_ADD, @TIME_ADD, @DATE_UPDATE, @TIME_UPDATE, @UPDATE_BY, @USER_ROLE, @USER_NAME, @USER_PASSWORD, @STATUS_CODE)"
                'first line        
                'paramList.Add("@ADD_BY", hashtable("addBy"))
                'paramList.Add("@DATE_ADD", hashtable("datetimeAddDATE"))
                'paramList.Add("@TIME_ADD", hashtable("datetimeAddTIME"))
                'paramList.Add("@DATE_UPDATE", hashtable("datetimeUpdateDATE"))
                'paramList.Add("@TIME_UPDATE", hashtable("datetimeUpdateTIME"))
                'paramList.Add("@UPDATE_BY", hashtable("updateBy"))
                'paramList.Add("@STATUS_CODE", hashtable("statusCode"))
                'sec line
                'paramList = New Hashtable()

                paramList.Add("@USER_ID", hashtable("welderId"))
                paramList.Add("@USER_FULL_NAME", hashtable("welderName"))
                paramList.Add("@USER_ROLE", "WELDER")
                paramList.Add("@USER_NAME", hashtable("userName"))
                paramList.Add("@USER_PASSWORD", hashtable("pdaPassword"))
                success = ExecuteSQL(SQL, paramList)
            Else
                success = False
            End If
        End If

        Return success
    End Function
End Class